﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Characters;
using The_Chronicles_of_Asku.Areas.Tomb_Floors;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10;
using The_Chronicles_of_Asku.Areas;

namespace The_Chronicles_of_Asku
{
    class MainGame
    {
        Hero myHero;

        public MainGame()
        {
            Training training = new Training();
            Skeleton skel = new Skeleton();
            Necromancer necro = new Necromancer();
            Undead zombie = new Undead();
            SecondTraining trainingTwo = new SecondTraining();
            ThirdTraining trainingThree = new ThirdTraining();
            Inn hotel = new Inn();
            Battle battle = new Battle();
            Mob mob = new Mob();
            myHero = new Hero();
            FloorOne one = new FloorOne();
            FloorTwo two = new FloorTwo();
            FloorThree three = new FloorThree();
            FloorFour four = new FloorFour();
            FloorFive five = new FloorFive();
            Shop store = new Shop();


            CharacterLoadSave loadSave = new CharacterLoadSave();
            Console.WriteLine("Do you wish to load your character? (1) Yes (2) No");
            string loadAnswer = Console.ReadLine();
            if (loadAnswer == "1")
            {
                loadSave.Load(myHero, hotel, training, one, two, three, four, five);
            }

            Hero.Initialize(myHero);

            Console.WriteLine(GameText.MainGameOptions);

            Console.WriteLine();
            string choice = Console.ReadLine();
            Console.WriteLine();

            while (choice != "11")
            {
                if (choice == "1")
                {
                    hotel.Greeting(myHero);
                }

                else if (choice == "2")
                {
                    if (hotel.completeFirst == true)
                    {
                        Console.WriteLine(GameText.FightMobOptions);
                        string choiceTraining = Console.ReadLine();
                        Console.WriteLine();
                        if (choiceTraining == "1")
                        {
                            training.entrance(myHero, skel);
                        }
                        if (choiceTraining == "2")
                        {
                            trainingTwo.entrance(myHero, necro);
                        }
                        if (choiceTraining == "3")
                        {
                            trainingThree.entrance(myHero, zombie);
                        }
                    }

                    else
                    {
                        Console.WriteLine(GameText.FightDoInnFirst);
                    }

                }

                else if (choice == "3")
                {
                    if (training.complete == true)
                    {
                        FloorSelector tombSelector = new FloorSelector();
                        tombSelector.Select(myHero, mob);
                    }

                    else
                    {
                        Console.WriteLine("You must complete training against a skeleton before you are permitted to enter the tomb.");
                    }
                }

                else if (choice == "4")
                {
                    if (training.complete == true)
                    {
                        FloorSelector tombSelector = new FloorSelector();
                        tombSelector.SelectEndGame(myHero, mob);
                    }

                    else
                    {
                        Console.WriteLine("You must complete training against a skeleton before you are permitted to enter the dungeon.");
                    }
                }

                else if (choice == "5")
                {
                    if (training.complete == true)
                    {
                        FloorSelector tombSelector = new FloorSelector();
                        tombSelector.SelectForest(myHero, mob);
                    }

                    else
                    {
                        Console.WriteLine("You must complete training against a skeleton before you are permitted to enter the forest.");
                    }
                }

                else if (choice == "6")
                {
                    if (training.complete == true)
                    {
                        FloorSelector tombSelector = new FloorSelector();
                        tombSelector.SelectTower(myHero, mob);
                    }

                    else
                    {
                        Console.WriteLine("You must complete training against a skeleton before you are permitted to enter the forest.");
                    }
                }

                else if (choice == "7")
                {
                    store.Store(myHero);
                }

                else if (choice == "8")
                {
                    myHero.DisplayStats(myHero);
                }

                else if (choice == "9")
                {
                    loadSave.Save(myHero, hotel, training, one, two, three, four, five);
                }

                else if (choice == "10")
                {
                    Console.Clear();
                    Console.WriteLine(GameText.Credits);
                }

                //else if (choice == "11")
                //{
                //    myHero.xp = 24500000;
                //    myHero.gold = 1000000;
                //}


                Console.ReadLine();
                Console.Clear();
                Console.WriteLine(GameText.MainGameOptions);


                choice = Console.ReadLine();
                Console.WriteLine();
            }

        }
    }
}